package com.pioneer.swing.ui;

import com.pioneer.swing.PioneerApp;
import com.pioneer.swing.SecurityRoles;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JMenu;

public class MainMenu
	extends JMenuBar{
	
	public MainMenu(ActionListener listener){
		JMenu menu = new JMenu(UIConstants.MENU_BAR_ACTION);
		menu.setMnemonic(KeyEvent.VK_A);
		
		JMenuItem menuItem = null;
		
		if ((PioneerApp.getCurrentRole().equals(SecurityRoles.ADMINISTRATOR)) ||
			(PioneerApp.getCurrentRole().equals(SecurityRoles.METALS_USER)))
		{
			menuItem = new JMenuItem(UIConstants.COMMAND_OPEN_MANIFESTS);
			menuItem.setMnemonic(KeyEvent.VK_M);
			menuItem.setActionCommand(UIConstants.COMMAND_OPEN_MANIFESTS);
			menuItem.addActionListener(listener);
			menu.add(menuItem);
		}
		
		if ((PioneerApp.getCurrentRole().equals(SecurityRoles.ADMINISTRATOR)) ||
			(PioneerApp.getCurrentRole().equals(SecurityRoles.JOBQUOTE_USER))  ||
			(PioneerApp.getCurrentRole().equals(SecurityRoles.JOBQUOTE_POWERUSER)) )
		{
			menuItem = new JMenuItem(UIConstants.COMMAND_OPEN_JOBS);
			menuItem.setMnemonic(KeyEvent.VK_J);
			menuItem.setActionCommand(UIConstants.COMMAND_OPEN_JOBS);
			menuItem.addActionListener(listener);
			menu.add(menuItem);
	    }
		/*
		menuItem = new JMenuItem(UIConstants.COMMAND_OPEN_CHAT);
		menuItem.setMnemonic(KeyEvent.VK_C);
		menuItem.setActionCommand(UIConstants.COMMAND_OPEN_CHAT);
		menuItem.addActionListener(listener);
		menu.add(menuItem);*/
		
		menuItem = new JMenuItem("Quit");
		menuItem.setMnemonic(KeyEvent.VK_Q);
		menuItem.addActionListener(listener);
		menu.add(menuItem);
		
		add(menu);
	}
	
	
}